<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="java.sql.*" %>
    <%request.setCharacterEncoding("UTF-8"); %>
    
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>统计学生信息</title>
</head>
<body>
<%
try{    int count = 0;
      Class.forName("com.mysql.jdbc.Driver");		
		String url = "jdbc:mysql://localhost:3306/jsp";	
		String username = "root";							
		String password = "root";							
		Connection conn = DriverManager.getConnection(url,username,password);
		String sql = "select count(*) from zhoujianyang";
		PreparedStatement ps = conn.prepareStatement(sql);
		Statement stmt = conn.createStatement();
		ResultSet rs = stmt.executeQuery(sql);
		if(rs.next()){
			count = rs.getInt(1);
		}
		     out.print("一共有"+count+"位同学");
		     
		     ps.close();
		     conn.close();
		     }catch(Exception e){
		     out.print("统计失败!");
		     e.printStackTrace();
		     }
		     %>
		     <br>
		     <a href="show.jsp">返回</a>

</body>
</html>